-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Populate package-path metadata into package context #3596
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive by questions.
porch/pkg/engine/engine.go
Outdated
@@ -104,10 +112,56 @@ func (cad *cadEngine) ListPackageRevisions(ctx context.Context, repositorySpec * | |||
return repo.ListPackageRevisions(ctx, filter) | |||
} | |||
|
|||
func (cad *cadEngine) CreatePackageRevision(ctx context.Context, repositoryObj *configapi.Repository, obj *api.PackageRevision) (repository.PackageRevision, error) { | |||
func buildPackageConfig(ctx context.Context, obj *api.PackageRevision, parent repository.PackageRevision) (*builtins.PackageConfig, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remind me.. what parent
means in context of porch ? few things popping up in my mind: upstream
package, parent
of a draft package and parent package of a subpackage (which we don't support in porch yet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I've got the best name, but parent
will let us establish a "position" of the package, in the same way that the directory structure does in git.
This proves to be a useful concept, I think, for value propagation and just to organize things.
This isn't done yet, but I would hope we could map this to directories in a git repo, so we would likely need this for CLI/server parity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
positionalParent
is how I will remember this now :)
type PackageConfig struct { | ||
// PackagePath is the path to the package, as determined by the names of the parent packages. | ||
// The path to a package is the parent package path joined with the package name. | ||
PackagePath string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you share what this is going to look like in CLI
and porch
based workflow. Is it relative ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So as I have it now, it's going to look like a directory path, myorg/apps/coolapp/dev
or something. I'm not certain what comes at the start of that (for example, should we try to make these globally unique, or at least allow that, vs being relative to the repository?) I'm also not certain whether we should include some notion of the package type, in which case the package path would end up looking like a GCP URL organizations/myorg/folders/apps/applications/coolapp/environments/dev
.
I figure we can iterate a bit here.
I think it would be the same in the CLI, though I'm not yet sure what we should do if you move it (which is the same problem we have if you rename the package - should we update the name in package-config.yaml?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example, should we try to make these globally unique, or at least allow that, vs being relative to the repository?
relative to the repository
in a deployment repo is the immediate usecase that I can relate with. Others are less clear to me as well. [Since we don't operate in context of repo in pure CLI experience, we can probably keep this no-op in CLI mode.]
About including package-type in the package paths feels like mixing logical view of your packages with the filesystem view (if they map 1:1 well, then we are good, otherwise screwed) :)
I think refactoring a package (like move package to new location or rename), I think the only way to handle them properly, will be to introduce refactoring functionality in our workflows for ex. pkg rename|move|....
if done through our tooling, we can update the underlying metadata automatically.
2871e2c
to
5fc4084
Compare
type PackageConfig struct { | ||
// PackagePath is the path to the package, as determined by the names of the parent packages. | ||
// The path to a package is the parent package path joined with the package name. | ||
PackagePath string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for example, should we try to make these globally unique, or at least allow that, vs being relative to the repository?
relative to the repository
in a deployment repo is the immediate usecase that I can relate with. Others are less clear to me as well. [Since we don't operate in context of repo in pure CLI experience, we can probably keep this no-op in CLI mode.]
About including package-type in the package paths feels like mixing logical view of your packages with the filesystem view (if they map 1:1 well, then we are good, otherwise screwed) :)
I think refactoring a package (like move package to new location or rename), I think the only way to handle them properly, will be to introduce refactoring functionality in our workflows for ex. pkg rename|move|....
if done through our tooling, we can update the underlying metadata automatically.
if packageConfig.PackagePath != "" { | ||
data[ConfigKeyPackagePath] = packageConfig.PackagePath | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing this conditional will ensure package-path is not added for kpt CLI
based workflows ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so, correct. It'll set it only if we have something to set.
Based on the discussion above, I sort of feel like we shouldn't be persisting either package-path or package-name into the package-context.yaml. Rather we should be generating it on the fly every time; then we don't have a conflict between directory name / directory path vs package-name/package-path.
The exception to that would be if we wanted the original name, so that if we generated something immutable it would be preserved. However, we do have other answers there, like trying to capture the name in the parameters in the kpt function pipeline or similar.
Sounds like we need to think more about the challenges here, but that we should merge this so we can gain some experience with how it behaves in practice.
return nil, fmt.Errorf("unrecognized built-in function %q", function) | ||
func newPackageContextGeneratorMutation(packageConfig *builtins.PackageConfig) (mutation, error) { | ||
runner := &builtins.PackageContextGenerator{ | ||
PackageConfig: packageConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it now. This confirms this will be done only in porch based workflow.
porch/pkg/engine/engine.go
Outdated
@@ -104,10 +112,56 @@ func (cad *cadEngine) ListPackageRevisions(ctx context.Context, repositorySpec * | |||
return repo.ListPackageRevisions(ctx, filter) | |||
} | |||
|
|||
func (cad *cadEngine) CreatePackageRevision(ctx context.Context, repositoryObj *configapi.Repository, obj *api.PackageRevision) (repository.PackageRevision, error) { | |||
func buildPackageConfig(ctx context.Context, obj *api.PackageRevision, parent repository.PackageRevision) (*builtins.PackageConfig, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
positionalParent
is how I will remember this now :)
bfe8617
to
c2d7e48
Compare
We construct a path based on the hierarchy of parent packages. This is useful for packages/package functions that want to construct values meaningful beyond just their package - for example domain names, GCP project IDs, bucket names, descriptions etc.
We construct a path based on the hierarchy of parent packages. This
is useful for packages/package functions that want to construct values
meaningful beyond just their package - for example domain names, GCP
project IDs, bucket names, descriptions etc.